package com.oracle.calllog.analyze.model;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class CountDuration implements WritableComparable<CountDuration>{
    // 统计指标：通话总次数
    private String callSum;
    // 统计指标：通话总时长
    private String callDurationSum;

    public CountDuration(){
        super();
    }

    public String getCallSum() {
        return callSum;
    }

    public void setCallSum(String callSum) {
        this.callSum = callSum;
    }

    public String getCallDurationSum() {
        return callDurationSum;
    }

    public void setCallDurationSum(String callDurationSum) {
        this.callDurationSum = callDurationSum;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(callSum);
        out.writeUTF(callDurationSum);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.callSum = in.readUTF();
        this.callDurationSum = in.readUTF();
    }

    @Override
    public int compareTo(CountDuration another) {
        CountDuration anotherBean = (CountDuration)another;
        if(this.callDurationSum.equals(anotherBean.callDurationSum)) {
            return -(this.callSum.compareTo(anotherBean.callSum));
        }
        return -(this.callDurationSum.compareTo(anotherBean.callDurationSum));
    }

    @Override
    public String toString() {
        return this.callDurationSum + "\t" + this.callSum;
    }
}
